package alogrithm;

/**
 * @author lbw
 * @date 2021/10/16 16:21
 * @version 1.0
 */
public class FoundOnceNumber {
    public int foundOnceNumber (int[] arr, int k) {
        // write code here
        int[] bitNum = new int[32];
        for (int i = 0 ; i < 32; ++i) {
            int sum = 0;
            for (int a : arr) {
                sum += (a >> i & 1);
            }
            bitNum[i] = sum;
        }
        int res = 0;
        for (int i = 0; i < 32; ++i) {
            if (bitNum[i] % k != 0) {
                res = 1 << i;
            }
        }
        return res;
    }
}
